package etnorservice.etnor_service.controller;

import etnorservice.etnor_service.result.Result;
import etnorservice.etnor_service.utils.ServerStatusChecker;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: cc
 * @Date: 2024/07/02/20:42
 **/
@RestController
public class ServerCheckController {
    @GetMapping("/checkServer")
    public Result checkServer(@Param("server") String server,@Param("port") Integer port){
        Result result = new Result();
        if(!server.equals("")){
            result.setData(ServerStatusChecker.isServerReachable(server));
            if(port!=null){
                result.setData(ServerStatusChecker.isPortOpen(server,port));
            }
        }


        return result;
    }
}
